#ifndef __OPM_H__
#define __OPM_H__

#include "user.h"
#include "part.h"
#include "timer.h"

#define OPM_DATA_LENGTH    32
#define OPM_COUNT   2

#define OPM_ERROR_BASE 100

enum opm_error{
    OPM_NO_DEVICE_FOUND = OPM_ERROR_BASE + 1,
    OPM_MESSAGE_LENGTH_ERROR
};

#define MAX_CHANNEL_NUMBER    128
#define M_POINT_COUNT       (20*1024)

typedef struct _opm_device{
    char busy;
    int exit;
    int uart_fd;
    int sample_flag;
    int print_flag;
    char* device_name;
    timer* timer;
    
    char version[20];
    int32_t temperature;
    uint32_t max_power_of_raw_detected_power_data;
    uint32_t freq_where_max_power;
    uint32_t total_number_of_channels;
    int16_t peak_optical_power[MAX_CHANNEL_NUMBER];
    uint16_t peak_optical_freq[MAX_CHANNEL_NUMBER];
    float peak_osnr1_optical_power[MAX_CHANNEL_NUMBER];
    float peak_freq[MAX_CHANNEL_NUMBER];
    float peak_osnr[MAX_CHANNEL_NUMBER];
    float peak_osnr2_optical_power[MAX_CHANNEL_NUMBER];
    uint32_t m_total_number_of_data_spectrumpoints;
    float m_points_of_power_of_spectrum[M_POINT_COUNT];
    float m_points_of_freq_of_the_spectrum[M_POINT_COUNT];
    float total_power_in_the_spectrum;

    char firmware_version[40];
    char assembly_serial_number[40];
    char filter_serial_number[40];
}opm_device;


cJSON* opm_parse(CMD_ID type,cJSON* param);  
void* opm_thread(void* param);
void opm_alarm_register(device_alarm_list* p_list);
#endif // !__OPM_H__
